# -*- coding = utf-8 -*-
# @time:2021/6/29 15:45
# Author:rongrongyu
# @file:run.py
# @Software:PyCharm
import unittest
import HTMLTestRunner

class Run:
    def run (self):
        #st_dir="demo"  #这是相对地址
        st_dir = "/ahttprunnerCD/demo"    #或者指定地址

        fp = open('D:/ahttprunnerCD/report/report/teemo_report.html', 'wb')
        runner = HTMLTestRunner.HTMLTestRunner(
            stream=fp,
            title='My Teemo:demo test',
            description=' Teemo: This demonstrates the report output by HTMLTestRunner.'
        )

        # eg1：第一种方法
        # 创建一个testsuite 实例

        #suite = unittest.TestSuite()
        # 把指定目录为test 开头的py文件都筛选出来 当作testcase
        discover =unittest.defaultTestLoader.discover(st_dir,pattern='test*.py',top_level_dir=None)

        # runner = unittest.TextTestRunner()
        #执行所有用例
        runner.run(discover)

if __name__ == '__main__':
    run = Run()
    run.run()



